package com.sgb.kjwl.view.ui.adapter.material;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.DemandHallListEntity;
import com.swgk.core.util.UiUtil;
import com.swgk.core.util.DateUtils;

import java.util.List;

/**
 * 作者:张磊
 * 日期:2021/1/8 0008
 * 说明:商品1.3.6 首页推荐item
 */
public class ShopNeedAdapter extends BaseQuickAdapter<DemandHallListEntity, BaseViewHolder> {


    public ShopNeedAdapter(List<DemandHallListEntity> beans) {
        super(R.layout.shopneed_item, beans);
    }

    @Override
    protected void convert(BaseViewHolder helper, final DemandHallListEntity item) {
        helper.setText(R.id.tv_companyName, item.getCompanyName())
                .setText(R.id.tv_property, item.getItems().size() > 0 ? item.getItems().get(0) : "")
                .setText(R.id.tv_arguments, item.getItems().size() > 1 ? item.getItems().get(1) : "")
                .setText(R.id.tv_publishTime, UiUtil.getKeyWordSpan(UiUtil.getColor(R.color.color_969696), "发布时间：" + item.getUpdateTime(), item.getUpdateTime()))
                .setText(R.id.tv_quoteTime, "报价截止：" + item.getDeadlineTime().split(" ")[0])
                .setImageResource(R.id.iv_tag, item.getStatus().equals("4") ? R.mipmap.termination_icon : item.getDeadlineTime() != null && !item.getDeadlineTime().equals("") ? (DateUtils.dateTo13Timestamp3(item.getDeadlineTime()) > System.currentTimeMillis() ? R.mipmap.inquiry_icon : R.mipmap.termination_icon) : R.mipmap.termination_icon)
                .setVisible(R.id.tv_property, item.getItems().size() > 0)
                .setVisible(R.id.tv_arguments, item.getItems().size() > 1);
    }
}